$(function() {
	$('#huodg12').datagrid({
		//请求地址
	    url:'../rule/getComputeRule',
	    columns:[[
	    	{field:'',title:'',checkbox:true},
			{field:'computeId',title:'计算规则编号',width:'10%'},
			{field:'computeName',title:'计算规则名称',width:'20%'},
			{field:'workTime',title:'工作时长',width:'10%'},
			{field:'remark',title:'备注',width:'15%'},
			{field:'maker',title:'创建者',width:'10%'},
			{field:'makeTime',title:'创建日期',width:'20%'},
			{field:'updateEmp',title:'修改者',width:'10%'},
			{field:'updateTime',title:'修改日期',width:'20%'},
			{field:'state',title:'状态',width:'10%',
				formatter : function(value, row, index) {
					if (row.state==='是') {
					var btns = "<a href='#' name='opera12' class='easyui-linkbutton' ></a>";
					return btns;
					}
				}
			} ] ],
			onLoadSuccess : function() {
				$("a[name='opera12']").linkbutton({
					plain : true,
					iconCls : 'icon-edit'
				}); 
				$("a[name='opera12']").bind('click',function(){
					var rows = $('#huodg12').datagrid('getSelected');
						$("#computeId").val(rows.computeId);
						$("#computeName").val(rows.computeName);
						$("#workTime").val(rows.workTime);
						$("#remark").val(rows.remark);
						$("#maker").val(rows.maker);
						$("#makeTime").val(rows.makeTime);
						$("#huodd12").window("open");
				})
		},
		onLoadError:function(data){
			alert('加载失败');
		},
	    width:'100%',
	    fit:true,
	    //fit:true
	    fitColumns:true,
	    //隔行变色
	    striped:true,
	    nowrap:true,
	    //显示行号
	    rownumbers:true,
	    //设置单选
	    singleSelect:true,
		toolbar:'#huotb12',
		//显示分页栏
		pagination:true,
		//设置每页大小
		pageSize:5,
		//可选的每页大小
		pageList:[5,10,20,50]
	});
});
 function searchname(value){
	 $('#huodg12').datagrid('load','../rule/serchComputeRule?computeName='+value);
} 
	function removeit(){
		var rows = $('#huodg12').datagrid('getSelections');
		if(rows.length > 0){
			$.messager.confirm('请确认','您确定要删除当前所有选中的项目吗？',function(r){
				if(r){
					var computes = [];
					for(var i = 0; i < rows.length; i++){
						computes.push(rows[i].computeId)
					}
					var huo_rowData = JSON.stringify(computes);
					alert(huo_rowData);
					$.ajax({
						url : "../rule/deletecomputeRule",
						data : {"huo_rowData" : huo_rowData},
						success : function(e) {
							if (e == "ok") {
                               alert("删除成功");
                               $('#huodg12').datagrid('load');
							}
						}
					});
				}
			 })
			}
	}